package com.wechatpay.v3.sdk.data;

import java.io.Serializable;

/**
 * 微信支付退款请求数据封装
 *
 * @author liuyi <liuy@pvc123.com>
 * @since 2021/8/5
 */
public class WechatRefundRequestData implements Serializable {

    /** 原支付交易对应的商户订单号 */
    private String out_trade_no;
    /** 商户系统内部的退款单号，商户系统内部唯一 */
    private String out_refund_no;
    /** 退款原因,会在下发给用户的退款消息中体现退款原因 */
    private String reason;
    /** 异步接收微信支付退款结果通知的回调地址,如果参数中传了notify_url，则商户平台上配置的回调地址将不会生效，优先回调当前传的这个地址 */
    private String notify_url;
    /** 金额信息 */
    private Amount amount;

    public WechatRefundRequestData(String out_trade_no, String out_refund_no, String reason, String notify_url, int refund, int total) {
        this.out_trade_no = out_trade_no;
        this.out_refund_no = out_refund_no;
        this.reason = reason;
        this.notify_url = notify_url;
        this.amount = new Amount(refund,total);
    }

    public String getOut_trade_no() {
        return out_trade_no;
    }

    public WechatRefundRequestData setOut_trade_no(String out_trade_no) {
        this.out_trade_no = out_trade_no;
        return this;
    }

    public String getOut_refund_no() {
        return out_refund_no;
    }

    public WechatRefundRequestData setOut_refund_no(String out_refund_no) {
        this.out_refund_no = out_refund_no;
        return this;
    }

    public String getReason() {
        return reason;
    }

    public WechatRefundRequestData setReason(String reason) {
        this.reason = reason;
        return this;
    }

    public String getNotify_url() {
        return notify_url;
    }

    public WechatRefundRequestData setNotify_url(String notify_url) {
        this.notify_url = notify_url;
        return this;
    }

    public Amount getAmount() {
        return amount;
    }

    public WechatRefundRequestData setAmount(Amount amount) {
        this.amount = amount;
        return this;
    }

    public static class Amount {

        /** 退款金额,不能超过原订单支付金额 */
        private int refund;
        /** 原支付交易的订单总金额 */
        private int total;
        /** 只支持人民币：CNY */
        private String currency = "CNY";

        public Amount() {
        }

        public Amount(int refund, int total) {
            this.refund = refund;
            this.total = total;
        }

        public int getRefund() {
            return refund;
        }

        public Amount setRefund(int refund) {
            this.refund = refund;
            return this;
        }

        public int getTotal() {
            return total;
        }

        public Amount setTotal(int total) {
            this.total = total;
            return this;
        }

        public String getCurrency() {
            return currency;
        }

        public Amount setCurrency(String currency) {
            this.currency = currency;
            return this;
        }
    }
}
